import json
import datetime


def load_data(file_path):
    with open(file_path, 'r') as f:
        data = json.load(f)
    return data


def find_complement(small_list, large_list):
    small_set = set(small_list)
    large_set = set(large_list)

    # 找出补集
    complement = large_set - small_set
    return list(complement)

def parse_detail():
    data = load_data('detail.json')
    result = data.get('result')
    activity_extension_audit_list = result.get('activity_extension_audit_list')
    audit_list = result.get('audit_list')
    goods_id = result.get('goods_id')
    if activity_extension_audit_list is not None:
        for item in activity_extension_audit_list:
            audit_status = item.get('audit_status')
            need_show_merchant_submit_price_button = item.get('need_show_merchant_submit_price_button')
            update_time = item.get('update_time')
            dt_object = datetime.datetime.fromtimestamp(update_time / 1000)  # 转换为秒后生成 datetime 对象
            formatted_time = dt_object.strftime('%Y-%m-%d %H:%M:%S')  # 格式化输出
            # 毫秒时间戳转日期
            if audit_status == 1 and need_show_merchant_submit_price_button is True:
                print('需要抓取 activity_extension_audit_list', 'date == ',formatted_time,' == goods_id = ', goods_id, 'update_time = ', update_time,
                      need_show_merchant_submit_price_button)
    if audit_list is not None:
        for item in audit_list:
            status = item.get('status')
            created_at = item.get('created_at')
            need_show_merchant_submit_price_button = item.get('need_show_merchant_submit_price_button')
            if (status == 501 or status == 702) and need_show_merchant_submit_price_button == True:
                print('需要抓取 audit_list', goods_id, created_at, need_show_merchant_submit_price_button)

if __name__ == '__main__':
    list1 = [
        712037957407,
        712051958598,
        712052999747,
        712057594109,
        712456984653,
        721324937086,
        721401672148,
        733853670227,
        735469545603,
        735470710888,
        739290672329,
        754079056220,
        761792555968

    ]
    data = load_data('activiting.json')
    result = data.get('result').get('result')
    count = 0
    list2 = []
    for item in result:
        list2.append(item.get('bid_goods_id'))

    small_list = list1 if len(list1) < len(list2) else list2
    complement = find_complement(small_list, list2 if small_list == list1 else list1)

    print('list1', len(list1), '总集list2', len(list2), )
    print("小 list 的补集大小:", len(complement), complement)
    for index,item in enumerate(complement):
        print(index+1,item)

    print('=================================\n')
    parse_detail()
    print('=================================\n')
